//
//  PortraitDetailViewController.m
//  UIViewControllerTransitionDemo
//
//  Created by Guo Rui on 2017/7/6.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "PortraitDetailViewController.h"
#import "PotraitInteractiveController.h"
#import "PotraitAnimationController.h"

@interface PortraitDetailViewController ()<UIViewControllerTransitioningDelegate>
@property (strong, nonatomic) PotraitInteractiveController *interactiveController;
@end

@implementation PortraitDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.transitioningDelegate = self;
    
    self.interactiveController =  [[PotraitInteractiveController alloc] initWithViewController:self];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (id<UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id<UIViewControllerAnimatedTransitioning>)animator {
    return self.interactiveController.interactiving ? self.interactiveController : nil;
}

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    return [[PotraitAnimationController alloc] init];
}


- (void)dealloc {
    
    NSLog(@"\n************\n %@ dealloc \n************", self.class);
}
@end
